import os
import shutil


def delete_files(res_dir):
    # 检查目录下的每个文件和子目录
    for filename in os.listdir(res_dir):
        file_path = os.path.join(res_dir, filename)
        try:
            if os.path.isfile(file_path) or os.path.islink(file_path):
                os.unlink(file_path)  # 删除文件或链接
            elif os.path.isdir(file_path):
                shutil.rmtree(file_path)  # 删除目录及其所有内容
        except Exception as e:
            print('Failed to delete %s. Reason: %s' % (file_path, e))